#ifndef _CLIENT_H_
#define _CLIENT_H_
#include "../socket.h"
#include "../networkchat.h"
#include "../md5/md5class.h"
#include <pthread.h>

// Clasa ce contine toata logica partii de client
class Client {
public:
	void start();
	void stop();
	void monitorSocket();
	void monitorKeyboard();
	Client(const char *hostname, int portNumber, const char *username, const char *password);
	~Client();
	
	bool work; // devine false atunci cand trebuie oprite threadurile
	pthread_mutex_t mutex;
private:
	const char *md5(const char *str);
	
	void draw_get_msg(char *prompt, int last_row, char *partial_msg);
	void get_msg(char *prompt, int last_row, char *msg);
	void print_msg(int x, int y, char *msg);
	
	pthread_t keyboard_monitor;
	pthread_t socket_monitor;
	
	CMD5 m_md5;
	Socket m_socket;
	char *m_hostname, *m_username, *m_password;
	int m_portNumber;
	
	char *prompt;
	char msg[255];
	int row_max,col_max,x;
	bool auth_failed;
};

#endif
